using System;
using System.Text;
using System.Collections;
using System.Text.RegularExpressions;

namespace fuzzyKittenVNC
{
	/// <summary>
	/// Containerclass representing HTTP Header
	/// </summary>
	public class WebSocketHeader {
		public HEADER_TYPE type;
		public string ressource;
		/// <summary>
		/// Send or receive header?
		/// </summary>
		public enum HEADER_TYPE {
			HANDSHAKE_REQUEST 	= 0x0001,
			HANDSHAKE_RESPONSE	= 0x0002
		//	DATA_PACKAGE		= 0x0003
		}
		
		private Hashtable headerVals;			
		public byte[] keyAppendix;
		
		public WebSocketHeader(HEADER_TYPE type) {
			this.headerVals = new Hashtable();
			this.keyAppendix = new byte[8];
			this.type = type;
		}
		
		public ICollection getHeaders() {
			return this.headerVals.Keys;
	    }
	    


		public void addHeader(string name,string val) {
			this.addHeader(name,val,false);
		}
		public void addHeader(string name,string val,bool noTrim) {
			if(!this.headerVals.ContainsKey(name)) {
				ArrayList values = new ArrayList();
				values.Add(noTrim ? val : val);
				this.headerVals.Add(name,values);
			} else 
				((ArrayList) this.headerVals[val]).Add(val);
		}
		
		public ArrayList getHeader(string name) {
			if(this.headerVals.ContainsKey(name))
				return (ArrayList) this.headerVals[name];
			else 
				return (ArrayList) new ArrayList();
		}			
	}
}

